//
//  TDIsPickCarInstore.m
//  TBRentClient
//
//  Created by tonbright on 2018/6/30.
//  Copyright © 2018年 tonbright. All rights reserved.
//

#import "TDIsPickCarInstore.h"
#import "TDGetCarPlaceSelC.h"


@interface TDIsPickCarInstore ()
@property (nonatomic,strong)TBROnCarPlaceModel *onCarPlaceModel;
@end

@implementation TDIsPickCarInstore

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setImg_isPickInstore];
}

- (IBAction)selIsPickInstoreSel:(UIButton *)sender {
    if ([self.isPickInstore isEqualToString:@"1"]) {
        self.isPickInstore = @"2";
    }else {
        self.isPickInstore = @"1";
    }
    [self setImg_isPickInstore];
}


- (void)setImg_isPickInstore {
    if ([_isPickInstore isEqualToString:@"1"]) {
        [_btn_isPickInstore setImage:[UIImage imageNamed:@"试驾圆未选中"] forState:UIControlStateNormal];
        
        _lbe_returnDes.textColor = [UIColor clearColor];
        _lbe_onCarPlace.textColor = [UIColor clearColor];
        _view_return.backgroundColor = [UIColor clearColor];
        _btn_selStore.enabled = NO;
        
    }else {
        [_btn_isPickInstore setImage:[UIImage imageNamed:@"试驾圆选中"] forState:UIControlStateNormal];
        _lbe_returnDes.textColor = [UIColor blackColor];
        _lbe_onCarPlace.textColor = [UIColor blackColor];
        _view_return.backgroundColor = [UIColor colorWithHex:0xd6d6d6];
        _btn_selStore.enabled = YES;
    }
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}

- (IBAction)navBtnClick:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)jump2SelPlaceBtnClick:(UIButton *)sender {
    TDGetCarPlaceSelC *getCarPlaceSelC = [[TDGetCarPlaceSelC alloc] init];
    getCarPlaceSelC.isOnCarPlace = YES;
    __weak typeof(self) weakSelf = self;
    getCarPlaceSelC.onCarPlaceBlock = ^(TBROnCarPlaceModel *carPlaceModel) {
        weakSelf.onCarPlaceModel = carPlaceModel;
        weakSelf.lbe_onCarPlace.text = carPlaceModel.titleStr;
    };
    
    [self.navigationController pushViewController:getCarPlaceSelC animated:YES];
}


- (IBAction)finishBtnClick:(UIButton *)sender {
    if ([self.isPickInstore isEqualToString:@"2"]) {
        if ([self.lbe_onCarPlace.text isEqualToString:@"请输入取车地址"]) {
            self.noticeText = @"请选择送车上门的地址";
            return;
        }
    }
    if (self.isPickCarInstoreBlock) {
        self.isPickCarInstoreBlock(self.isPickInstore, self.onCarPlaceModel);
        [self.navigationController popViewControllerAnimated:YES];
    }
}



@end
